package com.zeyi.blog.social.gtiee;

import org.springframework.security.authentication.AbstractAuthenticationToken;

/**
 * @author 黎先森
 */
public class GiteeAuthToken extends AbstractAuthenticationToken {

    private static final long serialVersionUID = -2277974900126086369L;
    private final Object principal;

    public GiteeAuthToken(Object principal) {
        super(null);
        this.principal = principal;
        setAuthenticated(false);
    }

    @Override
    public Object getCredentials() {
        return null;
    }

    @Override
    public Object getPrincipal() {
        return this.principal;
    }

    @Override
    public void setAuthenticated(boolean authenticated) {
        if (authenticated) {
            throw new IllegalArgumentException("Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead");
        } else {
            super.setAuthenticated(false);
        }
    }

    @Override
    public void eraseCredentials() {
        super.eraseCredentials();
    }
}
